home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 4751 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.6 KB

  1. Path: info.uah.edu!oreo!gbacon
  2. From: gbacon@oreo (Greg Bacon)
  3. Newsgroups: comp.lang.c,comp.unix.shell,comp.unix.programmer,comp.unix.questions
  4. Subject: Re: 'getopt' problem..
  5. Followup-To: comp.lang.c,comp.unix.shell,comp.unix.programmer,comp.unix.questions
  6. Date: 6 Feb 1996 20:58:59 GMT
  7. Organization: The University of Alabama in Huntsville
  8. Message-ID: <4f8fej$nnk@info.uah.edu>
  9. References: <SRIDHAR_PANCHAPAKESAN.96Feb5162934@compton.tmai.com>
  10. Reply-To: gbacon@CS.UAH.Edu
  11. NNTP-Posting-Host: oreo.aspire.cs.uah.edu
  12. X-Newsreader: TIN [version 1.2 PL2]
  13.  
  14. Sridhar Panchapakesan (sridhar_panchapakesan@tmai.com) wrote:
  15. : I am trying to use 'getopt' to read a quoted string as options for a
  16. : program. It works fine when I try it from a shell (csh) but when I try
  17. : running it from a script using 'exec' it does not accept the entire the
  18. : entire quoted string as the option.
  19.  
  20. : e.g. ( test is the program name)
  21. : % test -f "-g -o 5" in.txt
  22. : ( getopt works fine. The string "-g -o 5" is read correctly into
  23. : optargs. Note that I have to use '-' (dash) in the string as a
  24. : requirement of the program itself.)
  25.  
  26. : However when I try it from the script file:
  27.  
  28. : exec test -f "\"-g -o 5\"" in.txt
  29.  
  30. : The getopt only recognizes "-g as the option for -f instead of "-g -o
  31. : 5".
  32.  
  33. : I would appreciate any help in this area..
  34.  
  35. : - Sridhar.
  36.  
  37. You do realize that test is a Bourne Shell built-in, don't you?
  38. Maybe you're after something like this:
  39.  
  40. /path/to/your/test -f '-g -o 5' in.txt
  41.  
  42. Hope this helps,
  43. Greg
  44. --
  45. Greg Bacon <gbacon@cs.uah.edu>
  46. University of Alabama in Huntsville
  47. CS Department Systems Support Team
  48.